 import axios from  'axios';
import {fromJS} from 'immutable';
import * as constants from './constants';
//定义方法

 const  changeList=(data)=>({
     type:constants.CHANGE_NEWS,
     News:fromJS(data)  //吧数据转为immutable类型
 })
export  const getContent=(url)=>{
    return (dispatch) => {


        axios.get(window.ip+encodeURI(url)).then((res)=>{
            console.log(res);
            dispatch(changeList(res.data.data));
        }).catch((err)=>{
            alert(err);
            dispatch(changeList([]));
            console.log('err-404');
        });
    }
};